const app=getApp();
const util=require('../../../utils/util')
Page({

  data: {
    openid:app.globalData.openid,
    goodsName:''
  },

  onLoad: function (options) {
    console.log(options.id);
    this.setData({
      goodsId: options.id,
      goodsName:options.goodsName,
      goodsimg:options.goodsimg
    })
  },
  // 获取评论
  getInputValue(e) {
    // console.log(e.detail.value);
    this.setData({
      comment:e.detail.value
    })
  },
  // 发布评论
  publishCommet() {
    wx.request({
      url: `${app.globalData.baseurl}order/addComment`,
      method: "POST",
      data:{
        goodsId:this.data.goodsId,
        comment:this.data.comment,
        openid:app.globalData.openid,
        nickName:app.globalData.userInfo.nickName,
        avatarUrl:app.globalData.userInfo.avatarUrl,
        time:util.formatTime(new Date()),
        goodsName: this.data.goodsName,
        goodsimg:this.data.goodsimg
      }
    }) 
    wx.showToast({
      title: '提交成功',
    })
    wx.navigateBack({
      delta:0,
      // url:'../../myOrder/myOrder'
    })
  }

})